package org.visionlibrary.image.filters.nonlinear;

import java.awt.Point;

import javax.media.jai.TiledImage;

import org.visionlibrary.image.model.WindowFilter;


public class Roberts extends WindowFilter {
	protected int getNewPixelVal(TiledImage src, Point p, int channel) {
		float first = getWindowPixelVal(src, dstPointInWindow, channel)
				- getWindowPixelVal(src, new Point(dstPointInWindow.x + 1,
						dstPointInWindow.y + 1), channel);
		float second = getWindowPixelVal(src, new Point(dstPointInWindow.x,
				dstPointInWindow.y + 1), channel)
				- getWindowPixelVal(src, new Point(dstPointInWindow.x + 1,
						dstPointInWindow.y), channel);

		float val = ((float) Math.sqrt((first * first) + (second * second)));
		return (int) val;
	}

	protected void setWindowProperties() {
		windowWidth = 3;
		windowHeight = 3;
		dstPointInWindow = new Point(1, 1);
	}
}
